package com.example.run_game;

import android.app.PendingIntent;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

public class GPSTracker{
	private int GPS_QUERY_RATE = 1500;
	private LocationManager locationManager;
	private Handler handler;
	
	
	private final LocationListener listener = new LocationListener(){
		public void onLocationChanged(Location location) {
			Message.obtain(handler, 1, location).sendToTarget();		
		}
		public void onProviderDisabled(String arg0) {
		}
		public void onProviderEnabled(String arg0) {	
		}
		public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
			System.out.println("PROVIDER STATUS HAS BEEN CHANGED");	
		}		
	};
	
	public GPSTracker(LocationManager lm, Handler h){
		locationManager = lm;
		handler = h;
	}

	public void startTracking() {
		System.out.println("GPS on");
		locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 
				GPSTracker.this.GPS_QUERY_RATE, 
				0, 
				listener);
	}
	
	public void stopTracking() {
		System.out.println("GPS off");
		locationManager.removeUpdates(listener);
	}

	public void getLocation() {
	}
	

}
